package com.xuxin.baby.presenter;

import com.xuxin.baby.bean.BaseBean;
import com.xuxin.baby.bean.UserDataBean;
import com.xuxin.baby.contract.UserContract;
import com.xuxin.baby.model.UserModel;

/**
 * Created by xu_xin
 * Created on 2020/10/23 0023
 * 个人信息
 */
public class UserPresenter implements UserContract.Presenter {
    private final UserModel model;
    private final UserContract.View view;

    public UserPresenter(UserContract.View view) {
        this.view = view;
        model = new UserModel();
    }

    @Override
    public void getUserData(String tenantId, String token, String memberId) {
        if (null != model) {
            model.getUserData(this, tenantId, token, memberId);
        }
    }

    @Override
    public void uploadAvatar(String tenantId, String token, String memberId, String avatar) {
        if (null != model) {
            model.uploadAvatar(this, tenantId, token, memberId, avatar);
        }
    }

    @Override
    public void updateUserData(String tenantId, String token, String memberId, String mobile,String avatar,
                               String nick, String birthday, String nation, String role, String birthAddress, String address) {
        if (null != model) {
            model.updateUserData(this, tenantId, token, memberId, mobile,avatar,
                    nick, birthday, nation, role, birthAddress, address);
        }
    }

    @Override
    public void onSuccess(UserDataBean userDataBean) {
        if (null != view) {
            view.onSuccess(userDataBean);
        }
    }

    @Override
    public void onImageSuccess(BaseBean baseBean) {
        if (null != view) {
            view.onImageSuccess(baseBean);
        }
    }

    @Override
    public void onSuccess(BaseBean baseBean) {
        if (null != view) {
            view.onSuccess(baseBean);
        }
    }

    /**
     * 以下内容复用(用于请求完成后的操作)
     */
    @Override
    public void onError(BaseBean baseBean) {
        if (null != view) {
            view.onError(baseBean);
        }
    }

    @Override
    public void onComplete() {
        if (null != view) {
            view.onComplete();
        }
    }
}